package com.bqtv.sport.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bqtv.sport.R
import com.bqtv.sport.databinding.ItemMatchDateMonthBinding
import com.chad.library.adapter4.BaseQuickAdapter

class MatchDateMonthAdapter :
    BaseQuickAdapter<String, MatchDateMonthAdapter.VH>() {
    public var check = -1;

    class VH(
        parent: ViewGroup,
        val binding: ItemMatchDateMonthBinding = ItemMatchDateMonthBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
        // 返回一个 ViewHolder
        return VH(parent)
    }

    override fun onBindViewHolder(holder: VH, position: Int, item: String?) {
        // 设置item数据
        if (check == position) {
            holder.binding.tvDay.setTextColor(context.resources.getColor(R.color.white))
            holder.binding.tvGames.setTextColor(context.resources.getColor(R.color.white))
            holder.binding.rlItem.setBackgroundColor(context.resources.getColor(R.color.transparent))
            holder.binding.ivCheck.visibility = View.VISIBLE
        } else {
            holder.binding.tvDay.setTextColor(context.resources.getColor(R.color.text_222222))
            holder.binding.tvGames.setTextColor(context.resources.getColor(R.color.text_999999))
            holder.binding.rlItem.setBackgroundResource(R.mipmap.bg_match_date_check)
            holder.binding.ivCheck.visibility = View.GONE
        }
    }
}